﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace RecruitmentProcessSystem
{
    public partial class frmMainRibbon : Form
    {
        public frmMainRibbon()
        {
            InitializeComponent();
        }

        private bool checkTab(String name)
        {
            for (int i = 0; i < tabControl1.Tabs.Count; i++)
            {
                if (tabControl1.Tabs[i].Text == name)
                {
                    tabControl1.SelectedTabIndex = i;
                    return true;
                }
            }
            return false;
        }

        private void buttonItem14_Click(object sender, EventArgs e)
        {
            if (checkTab("Vacancy Manager") == false)
            {
                TabItem tab = tabControl1.CreateTab("Vacancy Manager");
                frmVacancyManager frm = new frmVacancyManager();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }            
        }

        private void buttonItem15_Click(object sender, EventArgs e)
        {
            if (checkTab("Applicant Manager") == false)
            {
                TabItem tab = tabControl1.CreateTab("Applicant Manager");
                frmApplicantManager frm = new frmApplicantManager();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }            
        }

        private void buttonItem16_Click(object sender, EventArgs e)
        {
            if (checkTab("Interview Manager") == false)
            {
                TabItem tab = tabControl1.CreateTab("Interview Manager");
                frmInterviewManager frm = new frmInterviewManager();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }

        }

        private void buttonItem13_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tabControl1_TabItemClose(object sender, TabStripActionEventArgs e)
        {
            TabItem t = tabControl1.SelectedTab;
            tabControl1.Tabs.Remove(t);
        }

        private void buttonItem17_Click(object sender, EventArgs e)
        {
            if (checkTab("View Interview") == false)
            {
                TabItem tab = tabControl1.CreateTab("View Interview");
                frmViewInterview frm = new frmViewInterview();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
        }

        private void buttonItem18_Click(object sender, EventArgs e)
        {
            if (checkTab("View Applicant") == false)
            {
                TabItem tab = tabControl1.CreateTab("View Applicant");
                frmViewApplicant frm = new frmViewApplicant();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
        }

        private void buttonItem19_Click(object sender, EventArgs e)
        {
            if (checkTab("View Vacancy") == false)
            {
                TabItem tab = tabControl1.CreateTab("View Vacancy");
                frmViewVacancy frm = new frmViewVacancy();
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.TopLevel = false;
                tab.AttachedControl.Controls.Add(frm);
                frm.Show();
                tabControl1.SelectedTabIndex = tabControl1.Tabs.Count - 1;
            }
        }

        private void buttonItem12_Click(object sender, EventArgs e)
        {
            this.Close();
            Login frm = new Login();
            frm.Show();
        }
    }
}
